package com.qf.dao;

import com.qf.pojo.entity.TbRolePress;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface TbRolePressRepository extends JpaRepository<TbRolePress,Integer> {
    /**
     * 通过管理员id查询所有权限的id
     * @param roId 角色id
     * @return 权限id列表
     */
    @Query(value = "SELECT pr_id FROM tb_role_press WHERE ro_id = ?1",nativeQuery = true)
    List<Integer> findPermissionIdByRoleId(Integer roId);
    @Modifying
    @Transactional
    @Query(value ="delete from tb_role_press where ro_id = ?1",nativeQuery = true)
    void deleteByRoId(Integer roId);
}
